package com.zenith.yasoo;

import java.util.Locale;

import javax.servlet.http.Cookie;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;

import com.opensymphony.xwork2.ActionContext;
import com.zenith.yasoo.party.Person;
import com.zenith.yasoo.party.PersonAction;
import com.zenith.yasoo.party.PersonManager;
import com.zenith.yasoo.security.User;
import com.zui.base.BaseAction;

public class MainAction extends BaseAction {

	private static final long serialVersionUID = 1L;

	private static final Log log = LogFactory.getLog(PersonAction.class);

	public MainAction() {
	}

	public MainAction(PersonManager personManager) {
		this.personManager = personManager;
	}

	private Person person;


	// fields without getter method are not serialized
	private PersonManager personManager;

	public void setPersonManager(PersonManager personManager) {
		this.personManager = personManager;
	}



	public String view() {
		Person person = (Person) personManager.findById(new Integer(1));
		log.debug("view() method in class PersonAction is executed!");
		return "view";
	}

	public String edit() {
		Person person = (Person) personManager.findById(new Integer(1));
		log.debug("edit() method in class PersonAction is executed!");
		return "edit";
	}

	public String editNew() {
		log.debug("editNew() method in class PersonAction is executed!");
		return "editNew";
	}

	public String create() {
		Person person = new Person();
		person.setFirstName("zuizui");
		person.setLastName("z");
		personManager.saveEntity(person);

		log.debug("create() method in class PersonAction is executed!");
		return "view";
	}

	public String delete() {
		log.debug("delete() method in class PersonAction is executed!");
		return "index";
	}
	

	// public String getJSON() {
	// return jsonList();
	// }

	public Person getPerson() {
		return person;
	}

	public void setPerson(Person person) {
		this.person = person;
	}
}
